"""
DOCSTRING
"""

class Object( object ):
    pass

class CentralServer( Object ):
    """
    DOCSTRING
    """

    def __init__( self, storeLocation ):
        self._storeLocation = storeLocation
        self._intervalMethods = []

        for base in self.__class__.__bases__:
            if hasattr( base, "__init__" ):
                base.__init__( self )

        self._handleIntervalMethods()

    def _handleIntervalMethods( self ):
        for context in self._intervalMethods:
            interval, count, method = context

            context[1] = (context[1] + 1) % interval

            if not context[1]:
                method()

def CentralServerFactory( *args, **kwargs ):
    import os
    plugindir = 'plugins'

    bases = tuple()
    files = os.listdir( os.path.join( os.path.dirname( __file__ ), plugindir ) )
    for f in files:
        if f.endswith( ".py" ) and not f == "__init__.py":
            imp = __import__( "%s.%s.%s" % ( __file__.split(os.sep)[-2], plugindir, f[0:-3] ) )
            if hasattr( imp.plugins, f[0:-3] ):
                module = getattr( imp.plugins, f[0:-3] )
                if hasattr( module, f[0:-3] ):
                    obj = getattr( module, f[0:-3] )
                    bases += ( obj, )

    #noinspection PyAugmentAssignment
    CentralServer.__bases__ = bases + CentralServer.__bases__
    return CentralServer( *args, **kwargs )
